/**
 * 封装http的几种请求方式
 * **/ 

import service from "./index"

// 封装get/post/put/delete请求
const http = {
    /**
     * method: 请求方法
     * url: 请求地址
     * params: 请求参数
     * 
     * */
    get(url,params){
        const config = {
            method:'get',
            url:url
        }
        if(params){
            config.params = params
        }
        return service(config)
    },
    post(url,params){
        const config = {
            method:'post',
            url:url
        }
        if(params){
            config.data = params
        }
        return service(config)
    },
    put(url,params){
        const config = {
            method:'put',
            url:url
        }
        if(params){
            config.params = params
        }
        return service(config)
    },
    delete(url,params){
        const config = {
            method:'delete',
            url:url
        }
        if(params){
            config.params = params
        }
        return service(config)
    },

}

export default http
